/*

Copyright 2007 Renaun Erickson (http://renaun.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ignore
*/
package asfslib.api.familytree.v1
{

import mx.collections.ArrayCollection;

/**
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="searchPerson">
 *   &lt;complexContent>
 *     &lt;extension base="{http://api.familysearch.org/familytree/v1}personSummaryBase">
 *       &lt;sequence>
 *         &lt;element name="maxDeathYear" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="minBirthYear" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *       &lt;attribute name="ref" type="{http://www.w3.org/2001/XMLSchema}string" />
 *       &lt;attribute name="role" type="{http://api.familysearch.org/familytree/v1}role" />
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
public class SearchPerson extends PersonSummaryBase
{

    //--------------------------------------------------------------------------
    //
    //  Constants
    //
    //--------------------------------------------------------------------------
    
    public static function parseXML(xml:XML):SearchPerson
    {
    	if (xml.namespace("") != undefined) 
		{
		    default xml namespace = xml.namespace("");
		} 
		
		var person:SearchPerson = new SearchPerson();
		person.ref = xml.@ref;
		// TODO does this work for all searches
		person.name = xml.person.name.form.fullText;
		person.gender = xml.person.gender;
		person.minBirthYear = xml.person.minBirthYear;
		person.maxDeathYear = xml.person.maxDeathYear;
		
		var events:Array = new Array();
		// Create EventSummary list
		for each(var resultEvent:XML in xml.person.events.event)
		{
			events.push(EventSummary.parseXML(resultEvent));
		}
		person.events = new ArrayCollection(events);
		
		default xml namespace = new Namespace("");
		
    	return person;
    }
    
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------    
	
    //----------------------------------
    //  maxDeathYear
    //----------------------------------

    /**
     *  @private
     *  Storage for the maxDeathYear property.
     */
    private var _maxDeathYear:String = "";

    /**
     *  The maxDeathYear property
     *
     *  @default  = ""
     */
    public function get maxDeathYear():String
    {
        return _maxDeathYear;
    }

    /**
     *  @private
     */
    public function set maxDeathYear(value:String):void
    {
        _maxDeathYear = value;
    }


    //----------------------------------
    //  minBirthYear
    //----------------------------------

    /**
     *  @private
     *  Storage for the minBirthYear property.
     */
    private var _minBirthYear:String = "";

    /**
     *  The minBirthYear property
     *
     *  @default  = ""
     */
    public function get minBirthYear():String
    {
        return _minBirthYear;
    }

    /**
     *  @private
     */
    public function set minBirthYear(value:String):void
    {
        _minBirthYear = value;
    }


    //----------------------------------
    //  ref
    //----------------------------------

    /**
     *  @private
     *  Storage for the ref property.
     */
    private var _ref:String = "";

    /**
     *  The ref property
     *
     *  @default  = ""
     */
    public function get ref():String
    {
        return _ref;
    }

    /**
     *  @private
     */
    public function set ref(value:String):void
    {
        _ref = value;
    }


    //----------------------------------
    //  role
    //----------------------------------

    /**
     *  @private
     *  Storage for the role property.
     */
    private var _role:Role;

    /**
     *  The role property
     *
     *  @default 
     */
    public function get role():Role
    {
        return _role;
    }

    /**
     *  @private
     */
    public function set role(value:Role):void
    {
        _role = value;
    }

}
}
